<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:mtg="http://www.patelski.myself/jsf"
	xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

	<ui:define name="body">
		<h:form id="inventory" styleClass="edit">

			<rich:panel>
				<f:facet name="header">Card</f:facet>
				<h:panelGrid columns="2" columnClasses="fifty,fifty">

					<h:panelGroup>
						<mtg:cardQuickPanel card="#{inventoryHome.instance.card}" />
					</h:panelGroup>
					<h:panelGroup style="width:100%;height:100%;">


						<rich:panel styleClass="quickPanel">
							<f:facet name="header">#{inventoryHome.managed ? 'Edit' : 'Add'} Inventory</f:facet>

							<s:decorate id="haveDecoration" template="layout/edit.xhtml">
								<ui:define name="label">Owned</ui:define>
								<h:inputText id="have" required="true"
									value="#{inventoryHome.instance.have}" size="15">
									<a:support event="onblur" reRender="haveDecoration"
										bypassUpdates="true" />
								</h:inputText>
							</s:decorate>

							<s:decorate id="keepDecoration" template="layout/edit.xhtml">
								<ui:define name="label">Keep</ui:define>
								<h:inputText id="keep" required="true"
									value="#{inventoryHome.instance.keep}" size="15">
									<a:support event="onblur" reRender="keepDecoration"
										bypassUpdates="true" />
								</h:inputText>
							</s:decorate>

							<s:decorate id="buyAmountDecoration" template="layout/edit.xhtml">
								<ui:define name="label">Buy-price</ui:define>
								<h:inputText id="buyAmount" required="true"
									value="#{inventoryHome.instance.buyAmount}" size="15">
									<a:support event="onblur" reRender="buyAmountDecoration"
										bypassUpdates="true" />
								</h:inputText>
							</s:decorate>

							<s:decorate id="sellAmountDecoration"
								template="layout/edit.xhtml">
								<ui:define name="label">Sell-price</ui:define>
								<h:inputText id="sellAmount" required="true"
									value="#{inventoryHome.instance.sellAmount}" size="15">
									<a:support event="onblur" reRender="sellAmountDecoration"
										bypassUpdates="true" />
								</h:inputText>
							</s:decorate>

							<s:decorate id="totalAmountDecoration"
								template="layout/edit.xhtml">
								<ui:define name="label">Total spend</ui:define>
								<h:inputText id="totalAmount" required="true"
									value="#{inventoryHome.instance.totalAmount}" size="15">
									<a:support event="onblur" reRender="totalAmountDecoration"
										bypassUpdates="true" />
								</h:inputText>
							</s:decorate>

							<s:decorate id="noteDecoration"
								template="layout/edit.xhtml">
								<ui:define name="label">Note</ui:define>
								<h:inputText id="note"
									value="#{inventoryHome.instance.note}" size="25">
									<a:support event="onblur" reRender="noteDecoration"
										bypassUpdates="true" />
								</h:inputText>
							</s:decorate>

							<div style="clear: both"><span class="required">*</span>
							required fields</div>

						</rich:panel>
					</h:panelGroup>
				</h:panelGrid>
			</rich:panel>

			<div class="actionButtons"><h:commandButton id="save"
				value="Save" action="#{inventoryHome.persist}"
				disabled="#{!inventoryHome.wired}"
				rendered="#{!inventoryHome.managed}" /> <h:commandButton
				id="update" value="Save" action="#{inventoryHome.update}"
				rendered="#{inventoryHome.managed}" /> <h:commandButton id="delete"
				value="Delete" action="#{inventoryHome.remove}"
				rendered="#{inventoryHome.managed}" /> <s:button id="done"
				value="Done" propagation="end" view="/Inventory.xhtml"
				rendered="#{inventoryHome.managed}" /> <s:button id="cancel"
				value="Cancel" propagation="end"
				view="/#{empty inventoryFrom ? 'InventoryList' : inventoryFrom}.xhtml"
				rendered="#{!inventoryHome.managed}" /></div>
		</h:form>

	</ui:define>

</ui:composition>
